// components/merchantsItem/index.js
const { getDateDiff } = require('../../utils/utils')
const { fetch, newFetch } = require('../../utils/fetch')

Component({
    /**
     * 组件的属性列表
     */
    properties: {
        data: Object,
        isEdit: Boolean
    },

    /**
     * 组件的初始数据
     */
    data: {
        time: '',
        specificarea:''
    },

    /**
     * 组件的方法列表
     */
  methods: {
    jump(e) {
      var typeid = e.currentTarget.dataset.id;
      if(this.data.isEdit) {
        if(wx.getStorageSync('specificarea')) {
          this.setData({
            specificarea:wx.getStorageSync('specificarea')
          })
        }
        newFetch(`wx/store/${this.data.specificarea}/detail`, 'POST', {
          id: typeid
        }).then(res => {
          var details = encodeURIComponent(res.data.details);
          delete res.data['details']
          console.log(res.data, 'zheksldfsdlf')
          if(res.code==200) {
                wx.navigateTo({
                  url: '/pages/tenantlist/index?ediddata='+JSON.stringify(res.data)+'&editid='+typeid+'&details='+details
              })
          }
        })
      } else {
        
      }
      
      // wx.navigateTo({
      //   url: '/pages/businessdetails/index?id='+this.data.data.id,
      // })

      // wx.navigateTo({
      //   url: '/pages/businsimpledetails/index?id='+this.data.data.id,
      // })
    }
  },
    attached: function() {
          if(!this.data.data) {
            return;
        }
        let time = this.data.data.createDate && getDateDiff(this.data.data.createDate)
        this.setData({
            time
        })
    }
})
